home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 235 / Issue 235 - September 2007 - DPCS0907DVD.ISO / Extras / NetObjects Fusion / NOF10.exe / data1.cab / FSI / lib / nof / html / Document.js < prev    next >
Encoding:
Text File  |  2007-04-11  |  33.4 KB  |  1,102 lines

  1. /****i* SOURCE_FILE/INFO
  2.   *
  3.   * NAME
  4.   *  Document.js
  5.   *
  6.   * USAGE
  7.   *  Part of Netobjects JavaScript Library.
  8.   *
  9.   * COPYRIGHT
  10.   *  Copyright ⌐ 2000-2005 Website Pros, Inc.
  11.   *  All Rights Reserved.
  12.   *
  13.   *  This is an unpublished work protected by Website Pros, Inc.
  14.   *  as a trade secret, and is not to be used or disclosed except as
  15.   *  expressly provided in a written license agreement executed by
  16.   *  you and Website Pros, Inc.
  17.   *
  18.   *      <copyright@websitepros.com>
  19.   *
  20.   * NOTES
  21.   *  JavaScript code.
  22.   *
  23.   *****/
  24.  
  25. if (!IS.isModuleInitialized("IS.NOF.HTML.Document"))
  26. {
  27.   
  28.   /****h* NOF_JavaScript_Library/NOF.HTML.Container
  29.     *
  30.     * NAME
  31.     *  NOF.HTML.Container
  32.     *
  33.     * DESCRIPTION
  34.     *    
  35.     ****/
  36.   
  37.   /**
  38.     * constructor   
  39.     **/ 
  40.   function NOF_HTML_Container(_doc){
  41.     this.__proto__  = NOF_HTML_Container.prototype;
  42.   
  43.     this.doc = _doc;
  44.     this.components = new Array();
  45.   }
  46.   {
  47.     var method = NOF_HTML_Container.prototype;
  48.     method.addComponent    = function ( comp ){};
  49.     method.removeComponent = function ( comp ){};
  50.     method.getComponents   = function (){};
  51.   
  52.     /**
  53.      * function getDocument
  54.      *
  55.      * convenience method, in case somebody wants to access the document directly
  56.      * @return the document itself
  57.      */
  58.     method.getRawDoc = function () {
  59.       return this.doc;
  60.     }
  61.   
  62.     /**
  63.      * function write
  64.      *
  65.      * convenience method, in case somebody wants to write to the document
  66.      */
  67.     method.write = function (str) {
  68.       return this.doc.write(str);
  69.     }
  70.   }
  71.   HTML.__proto__.Container = NOF_HTML_Container;  
  72.   //NOF.__proto__.HTMLContainer  = NOF_HTML_Container;
  73.   
  74.   
  75.   /****h* NOF_JavaScript_Library/NOF.HTML.Document
  76.     *
  77.     * NAME
  78.     *  NOF.HTML.Document
  79.     *
  80.     * DESCRIPTION
  81.     *    
  82.     *   Html document, based on DOM used in IE and Netscape Gecko
  83.     *
  84.     ****/
  85.   /**
  86.     * constructor   
  87.     **/ 
  88.   function NOF_HTML_Doc( _doc ){
  89.     this.__proto__ = NOF_HTML_Doc.prototype;
  90.     this.SUPER ( _doc );
  91.     
  92.     this.propertyMap = new Array();  
  93.   }
  94.   NOF_HTML_Doc.inherits ( NOF.HTML.Container )
  95.   {
  96.     //var member = NOF_HTML_Doc.prototype;
  97.   
  98.     var method = NOF_HTML_Doc.prototype;
  99.   
  100.     /**
  101.      * function getElementType
  102.      *
  103.      * find out the type of the element based in the element
  104.      * @param element the html doc element
  105.      * @return the type of the element: 'text','textarea',
  106.      *         'multiple-select','radio','checkbox' etc in lowercase
  107.      */
  108.     method.getElementType = function (element) {
  109.       if (element != null) {
  110.         var elementType = element.type;
  111.         if (elementType != null) {
  112.           elementType = elementType.toLowerCase();
  113.         }
  114.         else {
  115.           if (element.length > 0) {
  116.             elementType = element[0].type;
  117.           }
  118.           if (elementType == null) {
  119.             elementType = element.nodeName;
  120.           }
  121.         }
  122.       }
  123.       else {
  124.         elementType = null;
  125.       }
  126.       return elementType.toLowerCase();
  127.     }
  128.   
  129.     /**
  130.      * function getElementById
  131.      *
  132.      * find out the element based on the element id
  133.      * @param elementId the id of the html doc element
  134.      * @return element: the html element itself
  135.      */
  136.     method.getElementById = function (elementId) {    
  137.       return this.doc.all[this.getProperty(elementId)];
  138.     }
  139.   
  140.     /**
  141.      *   setElementAttribute
  142.      *
  143.      * Sset any attribute what a dom element can have
  144.      * @param id the id of the html doc element
  145.      * @param attrName the name of the attribute to set
  146.      * @param attrValue the value of the attribute
  147.      **/
  148.     method.setElementAttribute = function (id, attrName, attrValue) {
  149.       var element = this.getElementById (id);
  150.   
  151.       if ((attrName != null && attrName.length > 0) && (element != null)) {
  152.         if (element.attributes[attrName] != null) {
  153.           element.attributes[attrName].value= attrValue;
  154.           return true
  155.         }
  156.       }
  157.       return false
  158.     }
  159.   
  160.   
  161.     /**
  162.      * function setElementValue
  163.      *
  164.      * set the value for an html element
  165.      * @param id the id of the html doc element
  166.      * @param value the value of the html doc element
  167.      * @return result:  true or false based on setvalue was succesfull or not
  168.      */
  169.     method.setElementValue = function (id, value) {
  170.       var element = this.getElementById (id);
  171.       var elementType = this.getElementType(element);
  172.       if (elementType == null) {
  173.         return false;
  174.       }
  175.   
  176.       if (elementType == 'checkbox') {
  177.         return this.setCheckBoxGroupValue(element, value);
  178.       }
  179.       else if (elementType == 'radio') {
  180.         return this.setRadioGroupValue(element, value);
  181.       }
  182.       else if (elementType.indexOf('select',0) == 0) {
  183.         return this.setSelectValues(element, value);
  184.       }
  185.       else if (elementType == 'span') {
  186.         return this.setSpanInnerText(element, value);
  187.       }
  188.       else if (elementType == 'label') {
  189.         return this.setSpanInnerText(element, value);
  190.       }
  191.       else {
  192.         element.value = value;
  193.         return true;
  194.       }
  195.       return false;
  196.     }
  197.   
  198.     /**
  199.      * function getElementValue
  200.      *
  201.      * set the value for an html element
  202.      * @param id the id of the html doc element
  203.      * @return result: the value of the html doc element
  204.      */
  205.     method.getElementValue = function (id) {
  206.       var element = this.getElementById (id);
  207.       var elementType = this.getElementType(element);
  208.   
  209.       if (elementType == 'checkbox') {
  210.         return this.getCheckBoxGroupValue(element);
  211.       }
  212.       else if (elementType == 'radio') {
  213.         return this.getRadioGroupValue(element);
  214.       }
  215.       else if (elementType.indexOf('select',0) == 0) {
  216.         return this.getSelectValues(element);
  217.       }
  218.       else if (elementType == 'span') {
  219.         return this.getSpanInnerText(element);
  220.       }
  221.       else if (elementType != null) {
  222.         return element.value;
  223.       }
  224.       return null;
  225.     }
  226.   
  227.     /**
  228.      * function cleanElementValue
  229.      *
  230.      * clean the value for an html element
  231.      * @param id the id of the html doc element
  232.      * @param
  233.      * @return result:  true or false based on clean value was succesfull or not
  234.      */
  235.     method.cleanElementValue = function (id) {
  236.       var element = this.getElementById (id);
  237.       var elementType = this.getElementType(element);
  238.       if (elementType == null) {
  239.         return false;
  240.       }
  241.   
  242.       if (elementType == 'checkbox') {
  243.         return this.uncheckCheckBoxGroupValue(element);
  244.       }
  245.       else if (elementType == 'radio') {
  246.         return this.uncheckRadioGroupValue(element);
  247.       }
  248.       else if (elementType.indexOf('select',0) == 0) {
  249.         return this.clearSelectValues(element);
  250.       }
  251.       else if (elementType == 'span') {
  252.         this.setSpanInnerText(element, "");
  253.       }
  254.       else {
  255.         element.value = "";
  256.         return true;
  257.       }
  258.       return false;
  259.     }
  260.   
  261.     /**
  262.      * function focusElement
  263.      *
  264.      * set the focus on this element
  265.      * @param id the id of the html doc element
  266.      */
  267.     method.focusElement = function ( id ) {
  268.       var element = this.getElementById (id);
  269.       if (element != null) {
  270.         element.focus ();
  271.       }
  272.     }
  273.   
  274.     /**
  275.      * function enableElement
  276.      *
  277.      * set the html element enabled (disabled = false)
  278.      * @param id the id of the html doc element
  279.      */
  280.     method.enableElement = function (id) {
  281.       var element = this.getElementById (id);
  282.       if (element != null) {
  283.         element.disabled = false;
  284.       }
  285.     }
  286.   
  287.     /**
  288.      * function disableElement
  289.      *
  290.      * set the html element disabled (disabled = true)
  291.      * @param id the id of the html doc element
  292.      */
  293.     method.disableElement = function (id) {
  294.       var element = this.getElementById (id);
  295.       if (element != null) {
  296.         element.disabled = true;
  297.       }
  298.     }
  299.   
  300.     /**
  301.      * function setElementItemAt
  302.      *
  303.      * set one element item (element has to be a container: radiogroup,checkboxgroup,select)
  304.      * if element exists in the list, its values will be updated. otherwise element will be
  305.      * added to the list
  306.      *
  307.      * @param id the id of the html doc element
  308.      * @param item the items for this element (can be type of array)
  309.      *            For select could be: [options.text,options.value] or value
  310.      * @param index  the index of the item in the elements item list
  311.      * @return result:  true or false based on setelements was succesfull or not
  312.      */
  313.     method.setElementItemAt = function (id, item, index) {
  314.       var element = this.getElementById(id);
  315.       var elementType = this.getElementType(element);
  316.       if (elementType == 'checkbox') {
  317.         // not implemented yet
  318.         // return this.setCheckBoxGroupList(element, listItems);
  319.         return false;
  320.       }
  321.       if (elementType == 'radio') {
  322.         // not implemented yet
  323.         // return this.setRadioGroupList(element, listItems);
  324.         return false;
  325.       }
  326.       if (elementType.indexOf('select') == 0) {
  327.         return this.setSelectListItemAt(element, item, index);
  328.       }
  329.       return false;
  330.     }
  331.   
  332.     /**
  333.      * function setElementItem
  334.      *
  335.      * set one element item (element has to be a container: radiogroup,checkboxgroup,select)
  336.      * if element exists in the list, its values will be updated. otherwise element will be
  337.      * added to the list
  338.      *
  339.      * @param id the id of the html doc element
  340.      * @param item the items for this element (can be type of array)
  341.      *            For select could be: [options.text,options.value] or value
  342.      * @return result:  true or false based on setelements was succesfull or not
  343.      */
  344.     method.setElementItem = function (id, item) {
  345.       var element = this.getElementById(id);
  346.       var elementType = this.getElementType(element);
  347.       if (elementType == 'checkbox') {
  348.         // not implemented yet
  349.         // return this.setCheckBoxGroupList(element, listItems);
  350.         return false;
  351.       }
  352.       if (elementType == 'radio') {
  353.         // not implemented yet
  354.         // return this.setRadioGroupList(element, listItems);
  355.         return false;
  356.       }
  357.       if (elementType.indexOf('select') == 0) {
  358.         return this.setSelectListItem(element, item);
  359.       }
  360.       return false;
  361.     }
  362.   
  363.     /**
  364.      * function setElementItems
  365.      *
  366.      * set the element items (element has to be a container: radiogroup,checkboxgroup,select
  367.      * @param id the id of the html doc element
  368.      * @param listItems the items for this element (can be type of array)
  369.      *            For select could be: [(options.text,options.value),{options.text,options.value),etc] or
  370.      *                                 [value, value,...]
  371.      * @return result:  true or false based on setelements was succesfull or not
  372.      */
  373.     method.setElementItems = function (id, listItems) {
  374.       var element = this.getElementById(id);
  375.       var elementType = this.getElementType(element);
  376.       if (elementType == 'checkbox') {
  377.         // not implemented yet
  378.         // return this.setCheckBoxGroupList(element, listItems);
  379.         return false;
  380.       }
  381.       if (elementType == 'radio') {
  382.         // not implemented yet
  383.         // return this.setRadioGroupList(element, listItems);
  384.         return false;
  385.       }
  386.       if (elementType.indexOf('select') == 0) {
  387.         //NOF.util_logging_ConsoleLogger_global.info ('set select list');
  388.         return this.setSelectList(element, listItems);
  389.       }
  390.       return false;
  391.     }
  392.   
  393.     /**
  394.         * function getElementItemAt
  395.         *
  396.         * return item from the element items (element has to be a container: radiogroup,checkboxgroup,select)
  397.         * with the specified index
  398.         * @param id the id of the html doc element
  399.         * @index the index of the item in the array
  400.         * @return item or null if index not in range
  401.         * For select item is [options.text,options.value]
  402.         */
  403.     method.getElementItemAt = function (id, index) {
  404.       var element = this.getElementById(id);
  405.       var elementType = this.getElementType(element);
  406.       if (elementType == 'checkbox') {
  407.         // not implemented yet
  408.         // return this.getCheckBoxElements(element);
  409.         return null;
  410.       }
  411.       if (elementType == 'radio') {
  412.         // not implemented yet
  413.         // return this.getRadioGroupElements(element);
  414.         return null;
  415.       }
  416.       if (elementType.indexOf('select') == 0) {
  417.         return this.getSelectListItemAt(element, index);
  418.       }
  419.       return null;
  420.     }
  421.   
  422.     /**
  423.      * function getElementItem
  424.      *
  425.      * return an item from the element items(element has to be a container: radiogroup,checkboxgroup,select)
  426.      * @param id the id of the html doc element
  427.      * @param key the key to look for in the items list (in select element, key is the option.value field)
  428.      * @return parameter  for this item or null if not succeeded
  429.      *
  430.      * return parameter for select is the option.text, while search key is the option.value
  431.      *
  432.      */
  433.     method.getElementItem = function (id, key) {
  434.       var element = this.getElementById(id);
  435.       var elementType = this.getElementType(element);
  436.       if (elementType == 'checkbox') {
  437.         // not implemented yet
  438.         // return this.getCheckBoxElements(element);
  439.         return null;
  440.       }
  441.       if (elementType == 'radio') {
  442.         // not implemented yet
  443.         // return this.getRadioGroupElements(element);
  444.         return null;
  445.       }
  446.       if (elementType.indexOf('select') == 0) {
  447.         return this.getSelectListItem(element, key);
  448.       }
  449.       return null;
  450.     }
  451.   
  452.     /**
  453.      * function getElementItems
  454.      *
  455.      * return the element items (element has to be a container: radiogroup,checkboxgroup,select)
  456.      * @param id the id of the html doc element
  457.      * @return listItems the items for this element or null if not succeeded
  458.      */
  459.     method.getElementItems = function (id) {
  460.       var element = this.getElementById(id);
  461.       var elementType = this.getElementType(element);
  462.       if (elementType == 'checkbox') {
  463.         // not implemented yet
  464.         // return this.getCheckBoxElements(element);
  465.         return null;
  466.       }
  467.       if (elementType == 'radio') {
  468.         // not implemented yet
  469.         // return this.getRadioGroupElements(element);
  470.         return null;
  471.       }
  472.       if (elementType.indexOf('select') == 0) {
  473.         return this.getSelectList(element);
  474.       }
  475.       return null;
  476.     }
  477.   
  478.     /**
  479.      * function isInElementItemList
  480.      *
  481.      * check if item is in between element items (element has to be a container: radiogroup,checkboxgroup,select)
  482.      * @param id the id of the html doc element
  483.      * @param cmpItem the item to compare
  484.      * @param isCaseSensitive true/false
  485.      * @return result:  true or false depending if element was found or not
  486.      */
  487.     method.isInElementItemList = function (id, cmpItem, isCaseSensitive) {
  488.       var element = this.getElementById(id);
  489.       var elementType = this.getElementType(element);
  490.       if (elementType == 'checkbox') {
  491.         // not implemented yet
  492.         // return this.isInCheckBoxGroupList(element, newItem, isCaseSensitive);
  493.         return false;
  494.       }
  495.       if (elementType == 'radio') {
  496.         // not implemented yet
  497.         // return this.isInRadioGroupList(element, newItem, isCaseSensitive);
  498.         return false;
  499.       }
  500.       if (elementType.indexOf('select') == 0) {
  501.         //NOF.util_logging_ConsoleLogger_global.info ('select in list?');
  502.         return this.isInSelectList(element, cmpItem, isCaseSensitive);
  503.       }
  504.       return false;
  505.     }
  506.   
  507.     /**
  508.      * function addElement
  509.      *
  510.      * add a new item to the element item list (element has to be a container: radiogroup,checkboxgroup,select)
  511.      * @param id the id of the html doc element
  512.      * @param newItem the new item for this element (can be type of array)
  513.      *            For select could be: [value,displayName] or value
  514.      * @return result:  true or false depending if element was added or not
  515.      */
  516.     method.addElement = function (id, newItem) {
  517.       var element = this.getElementById(id);
  518.       var elementType = this.getElementType(element);
  519.       if (elementType == 'checkbox') {
  520.         // not implemented yet
  521.         // return this.addCheckBoxElement(element, newItem);
  522.         return false;
  523.       }
  524.       if (elementType == 'radio') {
  525.         // not implemented yet
  526.         // return this.addRadioGroupElement(element, newItem);
  527.         return false;
  528.       }
  529.       if (elementType.indexOf('select') == 0) {
  530.         return this.addSelectElement(element, newItem);
  531.       }
  532.       return false;
  533.     }
  534.   
  535.     /**
  536.      * function removeElements
  537.      *
  538.      * remove items from the element item's list (element has to be a container: radiogroup,checkboxgroup,select)
  539.      * @param id the id of the html doc element
  540.      * @param itemsToRemo the items to remove
  541.      * @return result:  true or false depending if elements were removed or not
  542.      */
  543.     method.removeElements = function (id, itemsToRemove) {
  544.       var element = this.getElementById(id);
  545.       var elementType = this.getElementType(element);
  546.       if (elementType == 'checkbox') {
  547.         // not implemented yet
  548.         return this.removeCheckBoxElements(element, itemsToRemove);
  549.       }
  550.       if (elementType == 'radio') {
  551.         // not implemented yet
  552.         // return this.removeCheckBoxElements(element, itemsToRemove);
  553.         return false;
  554.       }
  555.       if (elementType.indexOf('select') == 0) {
  556.         return this.removeSelectElements(element, itemsToRemove);
  557.       }
  558.       return false;
  559.     }
  560.   
  561.     /**
  562.      * function initialize
  563.      *
  564.      * initialize html from resource file
  565.      * @param resource object
  566.      */
  567.     method.initialize = function (resource) {
  568.       this.parseAndInitializeDoc (resource);
  569.     /*
  570.       var pNode = this.doc;
  571.       this.parseAndInitializeTree(pNode, resource, "");
  572.     */
  573.     }
  574.   
  575.     method.parseAndInitializeDoc = function (/* NOF.HTML.App */ resource) {
  576.       var len = this.doc.all.length;
  577.       for (var i = 0; i < len; i++) {
  578.         var pNode = this.doc.all[i];
  579.         
  580.         if (pNode.nodeName == 'SPAN') {
  581.           var id = pNode.attributes.id;
  582.           if (id != null) {
  583.             var label = resource.getResourceProperty(id.value);
  584.             if (label != null) {
  585.               pNode.innerHTML = label;
  586.             }
  587.           }
  588.         }
  589.         else if (pNode.nodeName == 'LABEL') {
  590.           var id = pNode.attributes.id;
  591.           if (id != null) {
  592.             var label = resource.getResourceProperty(id.value);
  593.             if (label != null) {
  594.               pNode.innerHTML = label;
  595.             }
  596.           }
  597.         }      
  598.         else if (pNode.nodeName == 'INPUT' && pNode.type == 'button') {
  599.           if (pNode.attributes.id) {
  600.             var value = pNode.attributes.id.value;
  601.             if (value != null) {
  602.               var label = null;
  603.               label = resource.getResourceProperty(value);
  604.               if (label != null) {
  605.                 pNode.attributes.value.value = label;
  606.               }
  607.             }
  608.           }
  609.         }
  610.         else if (pNode.nodeName == 'SELECT') {
  611.           if (pNode.attributes.id) {
  612.             var list = pNode.options;
  613.             if (list.length > 0) {
  614.               var id = pNode.attributes.id.value;
  615.               for (var j=0;j<list.length;j++) {
  616.                 var label = null;
  617.                 label = resource.getResourceProperty(id + "." + list[j].value);                    
  618.                 if (label != null) {
  619.                   list[j].text = label;
  620.                 }
  621.               }
  622.             }
  623.           }
  624.         }
  625.       }
  626.     }
  627.   
  628.     method.parseAndInitializeTree = function (/* HTML DOM Node */ pNode, 
  629.                                               /* NOF.HTML.App */ resource, 
  630.                                               tabStr) {
  631.       // first check for id if not a resuorce
  632.       if (pNode.childNodes.length == 0) {
  633.         if (pNode.nodeName == 'SPAN') {
  634.           var id = pNode.attributes.id;
  635.           if (id != null) {
  636.             var label = resource.getResourceProperty(id.value);
  637.             if (label != null) {
  638.                 var textNode = this.doc.createTextNode(label);
  639.                 pNode.appendChild(textNode);
  640.             }
  641.           }
  642.         }
  643.         else if (pNode.nodeName == 'INPUT' && pNode.type == 'button') {
  644.           if (pNode.attributes.id) {
  645.             var value = pNode.attributes.id.value;
  646.             if (value != null) {
  647.               var label = null;
  648.               label = resource.getResourceProperty(value);
  649.               if (label != null) {
  650.                 pNode.attributes.value.value = label;
  651.               }
  652.             }
  653.           }
  654.         }
  655.       }
  656.       else {
  657.         for (var i=0; i < pNode.childNodes.length; i++) {
  658.           this.parseAndInitializeTree(pNode.childNodes[i], resource, tabStr + "   ");
  659.         }
  660.       }
  661.     }
  662.     
  663.     
  664.     /** method localizeNode
  665.     * Inserts strings coresponding to tag's id attributes from 
  666.     * <code>resource</code> object.
  667.     */
  668.     method.localizeNode = function (/*HTML Node*/ pNode, 
  669.                                     /*NOF.UTIL.ResourceBundle*/ resource) {
  670.                                                  
  671.       if (pNode.childNodes.length == 0) {
  672.           if (pNode.nodeName == 'SPAN' || pNode.nodeName == 'LABEL') {
  673.               var id = pNode.attributes.id;
  674.               if (id != null) {
  675.                 var label = resource.getProperty(id.value);
  676.                 if (label != null) {
  677.                     var textNode = this.doc.createTextNode(label);
  678.                     pNode.appendChild(textNode);
  679.                 }
  680.               }
  681.         }
  682.         else if (pNode.nodeName == 'INPUT' && pNode.type == 'button')
  683.               if (pNode.attributes.id) {
  684.                 var value = pNode.attributes.id.value;
  685.                 if (value != null) {
  686.                   var label = null;
  687.                   label = resource.getProperty(value);
  688.                   if (label != null) 
  689.                     pNode.attributes.value.value = label;
  690.                 }
  691.               }
  692.         
  693.       } else {
  694.         for (var i=0; i < pNode.childNodes.length; i++) 
  695.           this.localizeNode(pNode.childNodes[i], resource);
  696.       }
  697.     }
  698.   
  699.     // private functions
  700.     method.setCheckedFields = function (element, valueSet) {
  701.       var counter = 0;
  702.       if (element.length) {
  703.         for (var i=0;i<element.length;i++){
  704.           if (valueSet[element[i].value] == true) {
  705.             element[i].checked = true;
  706.             counter++;
  707.           }
  708.         }
  709.       }
  710.       else {
  711.         if (valueSet[element.value] == true) {
  712.           element.checked = true;
  713.           counter++;
  714.         }
  715.       }
  716.       if (counter > 0)
  717.         return true;
  718.       // no element found to set
  719.       return false;
  720.     }
  721.   
  722.     method.setRadioGroupValue = function (element, value) {
  723.       var valueSet = new Array();
  724.       valueSet[value] = true;
  725.       return this.setCheckedFields(element, valueSet);
  726.     }
  727.   
  728.     method.setCheckBoxGroupValue = function (element, value) {
  729.       var valueSet = new Array();
  730.       if (typeof value != 'string') {
  731.         for (var i=0;i<value.length;i++) {
  732.           valueSet[value[i]] = true;
  733.         }
  734.       }
  735.       else {
  736.         valueSet[value] = true;
  737.       }
  738.       return this.setCheckedFields(element, valueSet);
  739.     }
  740.   
  741.     method.setSelectedFields = function (element,valueSet, valueSetLength) {
  742.       if (element.options.length > 0) {
  743.         var counter = 0;
  744.         for (var i=0;i<element.options.length;i++){
  745.           if (valueSet[element.options[i].value] == true) {
  746.             element.options[i].selected = true;
  747.             counter++;
  748.           }
  749.         }
  750.         if (counter == valueSetLength)
  751.           return true;
  752.         return false;
  753.       }
  754.       return false;
  755.     }
  756.   
  757.     method.setSelectValues = function (element, value) {
  758.       var valueSet = new Array();
  759.       var valueSetLength = 1;
  760.       if (typeof value != 'string') {
  761.         if ((value.length > 1) && (element.type != 'select-multiple')) {
  762.           return false;
  763.         }
  764.         for (var i=0;i<value.length;i++) {
  765.           valueSet[value[i]] = true;          
  766.         }
  767.         valueSetLength = value.length;
  768.       }
  769.       else {
  770.         valueSet[value] = true;
  771.       }
  772.       return this.setSelectedFields(element, valueSet, valueSetLength);
  773.     }
  774.     
  775.     method.setSelectIndex = function (elementId, index) {    
  776.       var element;
  777.       if ( typeof elementId == "string" )        
  778.         element = this.getElementById(elementId);
  779.       else
  780.         return;
  781.       
  782.       element.selectedIndex = index;
  783.     }
  784.   
  785.   
  786.     method.setSpanInnerText = function (element, newLabel) {
  787.       var newTextNode = this.doc.createTextNode(newLabel);
  788.       if (element.childNodes.length > 0) {
  789.         element.childNodes[0].replaceNode (newTextNode);
  790.       }
  791.       else {
  792.         element.appendChild(newTextNode);
  793.       }
  794.       return true;
  795.     }
  796.     
  797.     method.getCheckedFieldValues = function (element, stopAtFirst) {
  798.       var values = new Array(); j = 0;
  799.       if (element.length) {
  800.         for (var i=0;i<element.length;i++){
  801.           if (element[i].checked == true) {
  802.             values[j] = element[i].value;
  803.             if (stopAtFirst) {
  804.               return values;
  805.             }
  806.             j++;
  807.           }
  808.         }
  809.       }
  810.       else {
  811.         if (element.checked == true) {
  812.           values[j] = element.value;
  813.         }
  814.       }
  815.       return values;
  816.     }
  817.   
  818.     method.getRadioGroupValue = function (element) {
  819.       return this.getCheckedFieldValues(element, true);
  820.     }
  821.   
  822.     method.getCheckBoxGroupValue = function (element) {
  823.       return this.getCheckedFieldValues(element, false);
  824.     }
  825.   
  826.     method.getSelectValues = function (element) {
  827.       if (element.options && element.options.length > 0) {
  828.         var values = new Array(); j = 0;
  829.         for (var i=0;i<element.options.length;i++){
  830.           if (element.options[i].selected == true) {
  831.             values[j] = element.options[i].value;
  832.             if (element.type != 'select-multiple') {
  833.               return values;
  834.             }
  835.             j++;
  836.           }
  837.         }
  838.         return values;
  839.       }
  840.       return null;
  841.     }
  842.   
  843.     method.getSpanInnerText = function (element) {
  844.       if (element.childNodes.length > 0) {
  845.         return element.childNodes[0].nodeValue;
  846.       }
  847.       return null;
  848.     }
  849.   
  850.     method.setSelectListItemAt = function (element, item, idx) {
  851.       var optionTags = this.getSelectOptionTags (item);
  852.       var listElements = element.options;
  853.       var newOption = new Option (optionTags[0], optionTags[1]);
  854.       listElements[idx] = newOption;
  855.       return true;
  856.     }
  857.   
  858.     method.setSelectListItem = function (element, item) {
  859.       var optionTags = this.getSelectOptionTags (item);
  860.   
  861.       var listElements = element.options;
  862.       var idx = listElements.length;
  863.       for (var i=0;i<idx;i++) {
  864.         if (listElements[i].value == optionTags[1]) {
  865.           listElements[i].text = optionTags[0];
  866.           return true;
  867.         }
  868.       }
  869.       var newOption = new Option (optionTags[0], optionTags[1]);
  870.       listElements[idx] = newOption;
  871.       return true;
  872.     }
  873.   
  874.     method.setSelectList = function (element, listItems) {
  875.       var displayName = "";
  876.       var value = "";
  877.       var listElements = element.options;
  878.       listElements.length = 0;
  879.       var idx = listItems.length;
  880.       for (var i=0;i<idx;i++) {
  881.         this.addOptionToSelect(listElements, listItems[i]);
  882.       }
  883.       return true;
  884.     }
  885.     
  886.     method.addOptionToSelect = function (sElement, oParams){
  887.       var optionTags = this.getSelectOptionTags ( oParams );
  888.       var oOption =  this.doc.createElement("OPTION");
  889.       sElement.options.add( oOption );
  890.       oOption.innerText = optionTags[0];
  891.       oOption.value     = optionTags[1];
  892.     }
  893.   
  894.     method.isInSelectList = function (element, cmpItem, isCaseSensitive) {
  895.       var listElements = element.options;
  896.       var idx = listElements.length;
  897.       if (idx > 0) {
  898.         if (!isCaseSensitive) {
  899.           cmpItem  = cmpItem.toLowerCase();
  900.         }
  901.         for (var i=0;i<idx;i++) {
  902.           var listItem = listElements[i].value;
  903.           if (!isCaseSensitive) {
  904.             listItem = listItem.toLowerCase();
  905.           }
  906.           if (listItem == cmpItem) {
  907.             return true;
  908.           }
  909.         }
  910.       }
  911.       return false;
  912.     }
  913.   
  914.     method.getSelectListItemAt = function (element, index) {
  915.       var listElements = element.options;
  916.       if (index >= listElements.length)
  917.         return null;
  918.   
  919.       var item = new Array(2);
  920.       item[0] = listElements[index].text;
  921.       item[1] = listElements[index].value;
  922.       return item;
  923.     }
  924.   
  925.     method.getSelectListItem = function (element, value) {
  926.       var listElements = element.options;
  927.       var idx = listElements.length;
  928.       var listItems = new Array(idx);
  929.       for (var i=0;i<idx;i++) {
  930.         if (value == listElements[i].value) {
  931.           return listElements[i].text;
  932.         }
  933.       }
  934.       return null;
  935.     }
  936.   
  937.     method.getSelectListItemIndex = function (element, value, text ) {
  938.       var listElements = element.options;
  939.       var idx = listElements.length;
  940.       var listItems = new Array( idx );
  941.       for ( var i=0; i < idx; i++ ) {
  942.         if ( value == listElements[i].value || text == listElements[i].text ) {
  943.           return i;
  944.         }
  945.       }
  946.       return -1;
  947.     }
  948.   
  949.     method.getSelectList = function (element) {
  950.       var listElements = element.options;
  951.       var idx = listElements.length;
  952.       var listItems = new Array(idx);
  953.       for (var i=0;i<idx;i++) {
  954.         listItems[i] = listElements[i].value;
  955.       }
  956.       return listItems;
  957.     }
  958.   
  959.   
  960.     method.addSelectElement = function (element, newItem) {
  961.       this.addOptionToSelect(element, newItem);
  962.       return true;
  963.     }
  964.   
  965.     method.removeCheckBoxElements = function (element, itemsToRemove) {
  966.       return false;
  967.     }
  968.   
  969.     method.removeSelectElements = function (element, itemsToRemove) {
  970.       var items = new Array(itemsToRemove.length);
  971.       for (var i=0;i<itemsToRemove.length;i++) {
  972.         items[itemsToRemove[i]] = true;
  973.       }
  974.   
  975.       var optionList = element.options;
  976.       if (optionList.length > 0) {
  977.         var i = 0;
  978.         var go = true;
  979.         while (go) {
  980.           if (items[optionList[i].value] == true) {
  981.             optionList[i] = null;
  982.             i = 0;
  983.           }
  984.           else {
  985.             i++;
  986.           }
  987.           if (i == optionList.length) {
  988.             go = false;
  989.           }
  990.         }
  991.       }
  992.       return true;
  993.     }
  994.   
  995.     method.clearCheckedFieldValues = function (element) {
  996.       if (element.length) {
  997.         for (var i=0;i<element.length;i++)
  998.           element[i].checked == false;
  999.       }
  1000.       else {
  1001.         element.checked = false;
  1002.       }
  1003.     }
  1004.   
  1005.     method.uncheckCheckBoxGroupValue = function (element) {
  1006.       this.clearCheckedFieldValues(element);
  1007.       return true;
  1008.     }
  1009.     method.uncheckRadioGroupValue = function (element) {
  1010.       this.clearCheckedFieldValues(element);
  1011.       return true;
  1012.     }
  1013.     method.clearSelectValues = function (element) {
  1014.       for (var i=0;i<element.options.length;i++) {
  1015.         element.options[i].selected = false;
  1016.       }
  1017.       return true;
  1018.     }
  1019.   
  1020.     method.getSelectOptionTags = function (newItem) {
  1021.       var optionTag = new Array(2);
  1022.       if (typeof newItem == 'string') {
  1023.         optionTag[0] = optionTag[1] = newItem;
  1024.       }
  1025.       else {
  1026.         optionTag[0] = optionTag[1] = newItem[0];
  1027.         if (newItem.length == 2) {
  1028.           optionTag[1] = newItem[1];
  1029.         }
  1030.       }
  1031.       return optionTag;
  1032.     }
  1033.     
  1034.     method.setPropertyMap = function (propertyMap) {
  1035.       this.propertyMap = propertyMap;
  1036.     }
  1037.     
  1038.     method.getPropertyMap = function () {
  1039.       return this.propertyMap;
  1040.     }
  1041.     
  1042.     method.getProperty = function (propertyName) {
  1043.       if (this.propertyMap[propertyName]) {
  1044.         return this.propertyMap[propertyName];
  1045.       }
  1046.       return propertyName;
  1047.     } 
  1048.     
  1049.     method.getSelectedIndexes = function (objectId){
  1050.     var indexList = new Array();
  1051.     var j = 0;
  1052.     
  1053.     var object;
  1054.     if ( typeof objectId == "string" )        
  1055.       object = this.getElementById(objectId);    
  1056.     else
  1057.       return;//\object = objectId;
  1058.       
  1059.     var elementType = this.getElementType(object);    
  1060.       
  1061.     if (elementType == null) {
  1062.       return null;
  1063.     }
  1064.     
  1065.     if (elementType == 'checkbox') {        
  1066.       for (var i = 0; i < object.options.length; i++){
  1067.         if (object.options[i].selected == true) {
  1068.           indexList[j] = i;
  1069.           if (object.type != 'select-multiple') {
  1070.             return i;
  1071.           }
  1072.           j++;
  1073.         }
  1074.       }
  1075.       return indexList;        
  1076.     }
  1077.       
  1078.     else if (elementType == 'radio') {
  1079.       for (var i = 0; i < object.options.length; i++){
  1080.         if (object.options[i].selected == true) 
  1081.           return i;            
  1082.       }
  1083.     }
  1084.       
  1085.     else if (elementType.indexOf('select',0) == 0) {
  1086.       for (var i = 0; i < object.options.length; i++){
  1087.         if (object.options[i].selected == true) {
  1088.           indexList[j] = object.options[i].value;
  1089.           if (object.type != 'select-multiple') {
  1090.             return i;
  1091.           }
  1092.           j++;
  1093.         }
  1094.       }
  1095.       return indexList;
  1096.     }        
  1097.     }
  1098.   }
  1099.   
  1100.     HTML.__proto__.Document = NOF_HTML_Doc;
  1101. }
  1102.